﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace Utility
{
    public class GLOBAL 
    {
        private static string _ServerNo = "";
        public static string ServerNo
        {
            get
            {
                _ServerNo = AppConf.GetAppConfig("ServerNo", "");
                return _ServerNo;
            }
            //set { GLOBAL._ServerNo = value; }
        }

        private static string _DomainName = "";
        public static string DomainName
        {
            get
            {
                _DomainName = AppConf.GetAppConfig("DomainName", "");
                return _DomainName;
            }
            //set { GLOBAL._DomainName = value; }
        }

        public static string CalcMethod
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["CalcMethod"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "MethodDefault3";
                }
                return tmp;
            }
        }

        public static int SmsNextWaitTime
        {
            get
            {
                string tmp1 = ConfigurationManager.AppSettings["SmsNextWaitTime"];
                int ret = 30;
                int.TryParse(tmp1, out ret);
                return ret;
            }
        }

        public static string BranchNo
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["BranchNo"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "0000000000";
                }
                return tmp;
            }
        }

        public static string PosNo
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["PosNo"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "0000000000";
                }
                return tmp;
            }
        }

        private static string _JHGateWay = "https://pay.swiftpass.cn/pay/gateway";
        public static string JHGateWay
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["JHLBS:GateWay"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _JHGateWay = temp;
                }
                return GLOBAL._JHGateWay;
            }
        }

        #region

        static public string GetDeviceTypeName(int deviceType)
        {
            string ret = "";
            switch (deviceType)
            {
                case 0x10: ret = "预付费阶梯费率表(民用)"; break;
                case 0x20: ret = "预付费计量表(民用)"; break;
                case 0x30: ret = "后付费计量表(民用)"; break;
                case 0x11: ret = "预付费阶梯费率表(工业)"; break;
                case 0x21: ret = "预付费计量表(工业)"; break;
                case 0x31: ret = "后付费计量表(工业)"; break;
            }
            return ret;
        }

        static public string GetDeviceTypeName(enumDeviceType deviceType)
        {
            string ret = "";
            switch (deviceType)
            {
                case enumDeviceType.PREPAYMONEY1: ret = "预付费阶梯费率表(民用)"; break;
                case enumDeviceType.PREPAYVOLUME1: ret = "预付费计量表(民用)"; break;
                case enumDeviceType.POSTPAY1: ret = "后付费计量表(民用)"; break;
                case enumDeviceType.PREPAYMONEY2: ret = "预付费阶梯费率表(工业)"; break;
                case enumDeviceType.PREPAYVOLUME2: ret = "预付费计量表(工业)"; break;
                case enumDeviceType.POSTPAY2: ret = "后付费计量表(工业)"; break;
            }
            return ret;
        }

        static public string GetTaskStateName(enumTaskState taskState)
        {
            string ret = "";
            switch (taskState)
            {
                case enumTaskState.READTOSEND: ret = "等待发送"; break;
                case enumTaskState.SENDOK: ret = "已经发送"; break;
                case enumTaskState.SUCCESS: ret = "任务成功"; break;
                case enumTaskState.TASKFAILED: ret = "任务失败"; break;
                case enumTaskState.CANCELED: ret = "任务被取消"; break;
                case enumTaskState.TIMEOUT: ret = "任务超时"; break;
                case enumTaskState.FAILEDTOSEND: ret = "发送数据失败"; break;
                case enumTaskState.OTHER: ret = "其他错误"; break;
            }
            return ret;
        }

        static public string GetDataTypeName(enumDataType dataType)
        {
            string ret = "";
            switch (dataType)
            {
                case enumDataType.REALTIME: ret = "实时数据"; break;
                case enumDataType.FREEZE: ret = "冻结数据"; break;
            }
            return ret;
        }

        static public string GetDataTypeName(int dataType)
        {
            string ret = "";
            switch (dataType)
            {
                case (int)enumDataType.REALTIME: ret = "实时数据"; break;
                case (int)enumDataType.FREEZE: ret = "冻结数据"; break;
            }
            return ret;
        }

        static public string GetFreezeTypeName(int FreezeType)
        {
            string ret = "";
            switch (FreezeType)
            {
                case 1: ret = "每月定时采集"; break;
                case 2: ret = "每天定时采集"; break;
                case 3: ret = "每小时采集"; break;
                case 4: ret = "每分钟采集"; break;
            }
            return ret;
        }

        static public string GetUpLoadTypeName(int UpLoadType)
        {
            string ret = "";
            switch (UpLoadType)
            {
                case 1: ret = "每月定时上传"; break;
                case 2: ret = "每天定时上传"; break;
                case 3: ret = "每小时上传"; break;
                case 4: ret = "每分钟上传"; break;
            }
            return ret;
        }

        #endregion

        #region 济华配置
        private static string _FileIP = "221.214.3.91:6769";
        public static string FileIP
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _FileIP = temp;
                }
                return GLOBAL._FileIP;
            }
        }

        private static string _FileUName = "bank";
        public static string FileUName
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["FileUName"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _FileUName = temp;
                }
                return GLOBAL._FileUName;
            }
        }

        private static string _FilePwd = "123456";
        public static string FilePwd
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["FilePwd"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _FilePwd = temp;
                }
                return GLOBAL._FilePwd;
            }
        }

        private static string _FilePath = "D:/ftp/BankFile";
        public static string FilePath
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["FilePath"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _FilePath = temp;
                }
                return GLOBAL._FilePath;
            }
        }

        //java的base64格式秘钥  
        public static string PRIVATEJAVAKEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAOV815iFNQzYOG2y"
                                                       + "wLh+xyGkkyjU/e4tbgP4oNvxixz/ROZ8gS4FYH2HiGpE0EU/8S8t5JCWH1EaYd5J"
                                                       + "yg8rQsh43rwH3sLFa7Zifu9FiO7TPaymvC26zqf7W2HiOsNMN1cWd4jXnoc/NrzR"
                                                       + "KbxIN9zZpHE2Z0Fs2Hl1acStxvDdAgMBAAECgYAFF2X5Hkt1A38NAABCl513Y51Y"
                                                       + "NJGFrUBZmjSHbK53cDppGq4LBVeEsXMXWHt+bdK+Bzig9JOxSvKM6fovp/gNS89H"
                                                       + "AmHxLnohXQvbc5f6D8pb4o1v4P1g8T7KS+xNIaeY81OuUYUySbcuire5BKhhjflR"
                                                       + "8/X+SJC8jZfsFppqwQJBAPecOmc+aX+SvxGB4Z02u27Kg/oeJDvMSsfVq6PuM3hT"
                                                       + "aIstiHQa0EGMADqB9Yuae0FpdYMZMfsSyoUNMDzKVAkCQQDtQ2smnwRV0IsBMRTL"
                                                       + "/LF/I0g0qOCS2/5eLWhL7UzuLAMoOpH1vBb2XZMN+0cyr01162oLWO7zLV2JzroG"
                                                       + "5/M1AkBnjGcELB6UYjsTSDygsXXa1Egy/g3rD/kp7tpTuNa/eCodIhKRc3EqKDEk"
                                                       + "Rpr4IcdvyHmDNLMpK2eUErrcgUR5AkB1GEjRjrk9AOcZd3ekFNokvOzt0ErFL/2h"
                                                       + "zRckIcFN6jrEp+NRO7q5bAUfaVwCD7JS+BQl9YY4TbNUR8pXjjHhAkAHIrEOLFni"
                                                       + "pt8iokZwNMaZwJoWAKNNECXFj9KTs4DVwXSz0moKltSxxf9MO04ZsAY2XDW+p+pH"
                                                       + "IhLgHYBdrnvD";
        public static string PUBLICJAVAKEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDlfNeYhTUM2DhtssC4fschpJMo"
                                                   + "1P3uLW4D+KDb8Ysc/0TmfIEuBWB9h4hqRNBFP/EvLeSQlh9RGmHeScoPK0LIeN68"
                                                   + "B97CxWu2Yn7vRYju0z2sprwtus6n+1th4jrDTDdXFneI156HPza80Sm8SDfc2aRx"
                                                   + "NmdBbNh5dWnErcbw3QIDAQAB";

        private static string _PUBLICCSHARPKEY;
        public static string PUBLICCSHARPKEY
        {
            get
            {
                _PUBLICCSHARPKEY = RSAConverter.RSAPublicKeyJava2DotNet(PUBLICJAVAKEY);
                return _PUBLICCSHARPKEY;
            }
        }

        private static string _PRIVATECSHARPKEY;
        public static string PRIVATECSHARPKEY
        {
            get
            {
                _PRIVATECSHARPKEY = RSAConverter.RSAPrivateKeyJava2DotNet(PRIVATEJAVAKEY);
                return _PRIVATECSHARPKEY;
            }
        }

        private static string _IPAddress;
        public static string IPAddress
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["IPAddress"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _IPAddress = temp;
                }
                return GLOBAL._IPAddress;
            }
        }

        private static string _IPPort;
        public static string IPPort
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["IPPort"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _IPPort = temp;
                }
                return GLOBAL._IPPort;
            }
        }

        private static string _BankOperator = "lbic";
        public static string BankOperator
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["BankOperator"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _BankOperator = temp;
                }
                return GLOBAL._BankOperator;
            }
        }

        private static string _BankNo = "IC";
        public static string BankNo
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["BankNo"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _BankNo = temp;
                }
                return GLOBAL._BankNo;
            }
        }


        private static int _Hour = 0;
        public static int Hour
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["Hour"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _Hour = Convert.ToInt32(temp);
                }
                return GLOBAL._Hour;
            }
        }

        private static int _Minute = 30;
        public static int Minute
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["Minute"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _Minute = Convert.ToInt32(temp);
                }
                return GLOBAL._Minute;
            }
        }

        private static string _AccountPath = "D:\\BankFile\\";
        public static string AccountPath 
        {
            get
            {
                string temp = System.Configuration.ConfigurationManager.AppSettings["AccountPath"];
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    _AccountPath = temp;
                }
                return GLOBAL._AccountPath;
            }
        }
        #endregion
    }

    //public class SYSCFG
    //{
    //    public static string CalcMethod
    //    {
    //        get
    //        {
    //            string tmp = ConfigurationManager.AppSettings["CalcMethod"];
    //            if (string.IsNullOrEmpty(tmp))
    //            {
    //                tmp = "MethodDefault3";
    //            }
    //            return tmp;
    //        }
    //    }

    //    public static int SmsNextWaitTime
    //    {
    //        get
    //        {
    //            string tmp1 = ConfigurationManager.AppSettings["SmsNextWaitTime"];
    //            int ret = 30;
    //            int.TryParse(tmp1, out ret);
    //            return ret;
    //        }
    //    }

    //}

    public class ALIPAYCFG
    {
        public static string partner
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["Alipay:partner"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "2088911034949967";
                }
                return tmp;
            }
        }

        public static string privatekey
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["Alipay:privatekey"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALQOnakHe2MedwuJaK7Z10SnFWwyR84N0F7ieUBUBJUl1/CyaOWC404oWsquS5l3ZHDnJ+lbM8CGvWHuL1GyZf9M6S4ZNPGlq8TEA10ZKmCNTl0uWOAhLkSnxXImd/Zd+Q7g6taRykBiF4mOTGNpg+2IYzrnRqsURrf/X/eexlV1AgMBAAECgYAXUIUtq+BYN0um3MYHTgHHy/LELcaKcdN3Vc/peneVcG8DpbZbcZVJO4R2FheH6aPB0syiNMMAvPGsypCp/XWjX4BI1VsizvM0KNsykOpmjyaTg7eFlgaga6+GshhPbFH1MiyeWndM/XFPDL0lvhSLJS5mBdtWUmqWUrqa7Cs5QQJBAOHNWdFu4ntfDBVI66Dnt7Lx0UWsQqzo309EPnD8Ub+opRve3lKdxkM7e1lsYC+9+gcLa/4vhVV6+uTkQXVKF20CQQDMIx6fnzLhebKWQHbGmyBE0WULZVIMq4ds5kBFHAbx5XRTBRNdWfxcVOQXbQANHfFH+n6Y7MmAQv9+AegJFMkpAkEA307DjgDYUORNwdsM1GN0466MpRfYFMJ03iKCkiCnBCFXsDl3q0LHaYQw1937PhvmYgMkuQvsE/58k9M8/S7Z/QJAHw1EjkFYKwYpDUP3DVTxfqZfeXFLHtREwGLx6dFOmSMvI6XFAVE72wuquomBFX21gx5ufXKfYBxQ4ukFU8ROqQJASVLbZwWnhyeLIruv0VlORqIqMEcvo+9cbpCN98qE0B3lu5CqJAM6ungRmaBHlzk5y0MbrwD4N2XFkSDxp71B5A==";
                }
                return tmp;
            }
        }

        public static string sellerid
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["Alipay:sellerid"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "3225287063@qq.com";
                }
                return tmp;
            }
        }
    }

    public class ALIDAYUCFG
    {
        public static string url
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["Alidayu:url"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = @"http://gw.api.taobao.com/router/rest";
                }
                return tmp;
            }
        }

        public static string app_key
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["Alidayu:app_key"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "23330496";
                }
                return tmp;
            }
        }

        public static string app_secret
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["Alidayu:app_secret"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "e4232e9c7354a8b88c59462095bcf6c3";
                }
                return tmp;
            }
        }

        public static string template_code_resetpwd
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["Alidayu:template_code_resetpwd"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "SMS_6385056";
                }
                return tmp;
            }
        }

        public static string sign_name_resetpwd
        {
            get
            {
                string tmp = ConfigurationManager.AppSettings["Alidayu:sign_name_resetpwd"];
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "注册验证";
                }
                return tmp;
            }
        }
    }

    public enum enumDeviceType : int
    {
        /// <summary> 预付费阶梯费率表(民用) </summary>
        PREPAYMONEY1 = 0x10,
        /// <summary> 预付费阶梯费率表(工业) </summary>
        PREPAYMONEY2 = 0x11,
        /// <summary> 预付费计量表(民用) </summary>
        PREPAYVOLUME1 = 0x20,
        /// <summary> 预付费计量表(工业) </summary>
        PREPAYVOLUME2 = 0x21,
        /// <summary> 后付费计量表(民用) </summary>
        POSTPAY1 = 0x30,
        /// <summary> 后付费计量表(工业) </summary>
        POSTPAY2 = 0x31
    }

    public enum enumTaskState : int
    {
        /*
        0--等待发送
        1—已经发送
        2—任务成功
        3—任务失败
        4—任务被取消
        5—任务超时
        6—发送数据失败
        */
        READTOSEND = 0,
        SENDOK = 1,
        SUCCESS = 2,
        TASKFAILED = 3,
        CANCELED = 4,
        TIMEOUT = 5,
        FAILEDTOSEND = 6,
        OTHER = 99
    }

    public enum enumDataType : int
    {
        /*
        数据类型(0-实时数据,1-冻结数据)
        */
        /// <summary> 0-实时数据 </summary>
        REALTIME = 0,
        /// <summary> 1-冻结数据 </summary>
        FREEZE = 1
    }
}
